package collections;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

/**
 * 测试 Collection 接口中的 size / isEmpty / contains / remove / toArray / clear
 */
public class CollectionTest1 {

    public static void main(String[] args) {

        Collection<Object> collection = new ArrayList<Object>();
        System.out.println( "size : " + collection.size() + " , is Empty : " + collection.isEmpty());

        collection.add( "蒋嘉豪" );
        collection.add( 1999 );
        collection.add( null );
        collection.add( "bboy" );

        System.out.println( "size : " + collection.size() + " , is Empty : " + collection.isEmpty());

        System.out.println( "*****************************************" );

        System.out.println( collection.contains( null ) );//true
        System.out.println( collection.contains( "null" ) );//false

        System.out.println( "*****************************************" );

        collection.remove(null );
        System.out.println( collection.remove( "蒋嘉豪") );
        System.out.println( "size : " + collection.size() + " , is Empty : " + collection.isEmpty());

        System.out.println( "*****************************************" );

        Object[] array = collection.toArray();
        System.out.println(Arrays.toString(array) );

        collection.clear();
        System.out.println( collection );
        System.out.println( "size : " + collection.size() + " , is Empty : " + collection.isEmpty());
    }
}
